import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:xindong/common/xindong_sezhi.dart';
import 'package:xindong/common/xindong_methods.dart';
import 'package:xindong/widgets/gift/xindong_songli_controller.dart';
import 'package:xindong/widgets/gift/view/xindong_songli_count_dialog.dart';

class XinDongSongLiSentButton extends StatelessWidget {
  const XinDongSongLiSentButton({super.key});

  @override
  Widget build(BuildContext context) {
    return Container(
      height: 36,
      clipBehavior: Clip.antiAlias,
      decoration: BoxDecoration(
        border: Border.all(color: DZColors.mainColor, width: 1.0),
        borderRadius: BorderRadius.circular(36),
      ),
      child: GetBuilder<XinDongSongLiController>(builder: (controller) {
        return Row(
          children: [
            GestureDetector(
              onTap: () {
                if (controller.selectGift?.cate_id == XinDongLiWuType.backpack) {
                  showToast("背包礼物暂不支持多送");
                  return;
                }

                // 弹窗
                XinDongSongLiCountDialog.show(context);
              },
              behavior: HitTestBehavior.opaque,
              child: Row(
                mainAxisSize: MainAxisSize.min,
                children: [
                  const SizedBox(width: 12),
                  ConstrainedBox(
                    constraints: const BoxConstraints(minWidth: 64.0 - 35.0),
                    child: Text(
                      "${controller.selectCount}",
                      textAlign: TextAlign.center,
                      maxLines: 1,
                      style: const TextStyle(fontSize: 14, fontWeight: FontWeight.w500, color: DZColors.titleColor),
                    ),
                  ),
                  Container(
                    width: 26,
                    alignment: Alignment.centerLeft,
                    child: const Icon(Icons.arrow_drop_up, color: DZColors.titleColor),
                  ),
                ],
              ),
            ),
            Container(
              width: 64,
              color: DZColors.mainColor,
              child: MaterialButton(
                textColor: Colors.white,
                onPressed: controller.onTapSend,
                child: const Text(
                  "赠送",
                  style: TextStyle(fontSize: 15, fontWeight: FontWeight.normal, height: 1.2),
                ),
              ),
            ),
          ],
        );
      }),
    );
  }
}
